package com.lc.lc3229;

public class Main {
	
	public static void main(String[] args) {
		
	}

}

class Solution {
    public long minimumOperations(int[] nums, int[] target) {
        int n = nums.length;
        long[] a = new long[n];
        long[] b = new long[n];
        for (int i = 0; i < n; i ++) {
        	a[i] = target[i] - nums[i];
        }
        b[0] = a[0];
        for (int i = 1; i < n; i ++) {
        	b[i] = a[i] - a[i - 1];
        }
        
        long ans1 = 0, ans2 = 0;
        for (int i = 0; i < n; i ++) {
        	if (b[i] > 0) {
        		ans1 += b[i];
        	} else {
        		ans2 += -b[i];
        	}
        }

        return Math.max(ans1, ans2);
    }
}
